/**
 * @author Michael
 * 
 * @returns snBoolean 
 * @param snInteger
 * 
 * @typeSig snBoolean Sleep(snInteger p1)
 * 
 * Sleep for p1 msec and return true.  Returns False if interrupted
 * 
 */
package sxe.core;

import snobject.snBoolean;
import snobject.snInteger;
import snobject.snObject;
import snobject.snObjectArgList;
import step.EvaluationFailure;
import step.FunctionWrapper;
import step.exceptions.ResourceUnavailableException;

public class sleep extends FunctionWrapper {

	@Override
	public snObject Call(snObjectArgList argv) throws EvaluationFailure,
			ClassCastException, ArrayIndexOutOfBoundsException,
			ResourceUnavailableException {

		snInteger p1 = argv.popInteger();
		
		try {
			Thread.sleep(p1.getInt());
		} catch (InterruptedException e) {
			e.printStackTrace();
			return snBoolean.FALSE;
		}
		
		return snBoolean.TRUE;
	}

}
